﻿using System;
using System.Collections.Generic;
using Fuse8.DomainFramework.Domain;

namespace Fuse8.DomainFramework.CacheService
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    /// <typeparam name="TKey"></typeparam>
    public interface IEntityCacheService<TEntity, TKey> : IEntityCacheServiceElement
        where TEntity : class, IEntityObject<TKey>
        where TKey : IComparable<TKey>, IEquatable<TKey> 
    {        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="entityObject"></param>
        void AddItemToCache(string cacheKey, TEntity entityObject);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="entityObjects"></param>
        void AddListToCache(string cacheKey, IList<TEntity> entityObjects);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        TEntity GetFromCache(string cacheKey);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        IList<TEntity> GetListFromCache(string cacheKey);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cacheKey"></param>
        void RemoveItemFromCache(string cacheKey);

        /// <summary>
        /// 
        /// </summary>
        void ClearCache();        

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityObject"></param>
        void ClearDependency(TEntity entityObject);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        void ClearDependency(TKey id);
		
        /// <summary>
        /// 
        /// </summary>
        /// <param name="successor"></param>
        void SetSuccessor(IEntityCacheService<TEntity, TKey> successor);

        /// <summary>
        /// 
        /// </summary>
        IEnumerable<CacheItemView> CacheItems { get; }

        /// <summary>
        /// 
        /// </summary>
        CacheServiceOptions CacheOptions { get; set; }
    }
}
